<?php
class AccountIndexAction extends BaseAction
{
    protected $http_method = 'get';
    public function __construct($uri)
    {
        parent::__construct($uri);
    }

    protected function logic()
    {
        if(isset($_COOKIE['access_token'])) {
            $m = new UserModel();
            //todo catch
            $token = $m->decryptToken($_COOKIE['access_token']); //todo move to __construct
            $user = $m->get($token['user_id']);
            $this->output['data']['user'] = $user;
            $this->output['tpl'] = 'accounts/index';
            return $this->output;
        }
        $this->output['http']['status_code'] = 302;
        $this->output['http']['uri'] = 'http://www.doubanxia.com/accounts/login';
        return $this->output;
    }
}
?>
